
import { observe, set } from './observer';
export function initState(instance) {

  // vm.setCtx(ctx);

  if (instance?.$entity?.data) initData(instance)
}
function initData(instance) {
  const data = instance._data = instance?.$entity?.data;
  // console.log(data);
  Object.keys(data).forEach(key => {
    proxy(instance, `_data`, key)
  });
  observe(data);
}
function proxy(target, sourceKey, key) {
  Object.defineProperty(target, key, {
    get() {
      return target[sourceKey][key]
    },
    set(val) {
      target[sourceKey][key] = val
    }
  })
}
